<template>
	<view>
		<view class="title">
			<!-- 动态绑定样式 -->
			<view :class="{active:show==1}" @tap="show=1" >
				精选文章
			</view>
			<view :class="{active:show==2}" @tap="suggest" >
				好物推荐
			</view>
		</view>
		<view class="12" v-show= "show==1">
			<view class="center">
				<view class="center-title">
					<view :class="{now:currentKind==item.id}"v-for = "item in kindlist" :key="item.id" @tap = "qiehuan(item.id)">
						<image :src="item.icons" mode=""></image>
					</view>
				</view>
			</view>
			<view class="find-center" v-for="item in aritlceList" :key = "item.id">
				<image :src="item.coverImg" mode=""></image>
				<view class="text">
					<text class = bigtext>{{item.title}}</text>
					<text>{{ item.author }}</text>
				</view>
			</view>
		</view>
		
		
		<view class="11" v-show= "show==2">
			这是好物推荐页面
		</view>
		
	</view>
</template>

<script>
	import http from "../../utils/http.js"
	export default {
		data() {
			return {
				id:'',
				show:'1',
				currentKind:'',
				kindlist:[],
				aritlceList:[],
			};
		},
		methods:{
			getkindlist(){
				http.get("/api/leju/front/kind/list").then(res => {
					console.log(res);
					var icons = [
						'../../static/images/chuangyi.png',
						'../../static/images/shipin.png',
						'../../static/images/fengge.png',
						'../../static/images/dengju.png'
					]
					for (var i = 0; i< res.data.data.length;i++){
						res.data.data[i].icons = icons[i]
					}
					this.kindlist = res.data.data;
					this.currentKind = res.data.data[0].id; 
				})
			},
			getseriesAll(){
				http.get("/api/leju/front/find/aritlceList",{
					kindId:this.currentKind
				}).then(res => {
					console.log(res);
					this.aritlceList = res.data.data.list;
				})
			},
			qiehuan(val){
				console.log(val);
				this.currentKind = val;
				http.get("/api/leju/front/find/aritlceList",{
					kindId:this.currentKind
				}).then(res => {
					// console.log(res);
					this.aritlceList = res.data.data.list;
				})
			},
			suggest(){
				this.show = 2;
				http.get("/api/leju/front/find/seriesAll").then(res=>{
					console.log(res,"好物推荐");
				})
			}
		},
		onShow() {
			this.getkindlist();
		},
		onLoad(){
			this.getkindlist();
			this.getseriesAll();
		},	
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f1ece7;
	}
	
	.title {
		width: 100%;
		height: 230rpx;
		background: #354e44;
		display: flex;
		justify-content: center;
	
		color: #fff;
	
		view {
			height: 60rpx;
			margin: 0 20rpx;
			margin-top: 100rpx;
		}
	
		.active {
			margin: 0 20rpx;
			margin-top: 100rpx;
			border-bottom: 2px solid #fff;
		}
	}
	
	.center {
		border-radius: 40rpx 40rpx 0 0;
		overflow: hidden;
		background: #f1ece7;
		margin-top: -40rpx;
	
		.center-title {
			height: 150rpx;
			width: 100%;
			display: flex;
			margin-top: 50rpx;
			justify-content: space-around;
	
			view {
				width: 84rpx;
				height: 84rpx;
				border-radius: 50%;
				background: #fff;
	          
	
				image {
					margin-top: 15rpx;
					margin-left: 15rpx;
					width: 60rpx;
					height: 60rpx;
				}
			}
	
			.now {
				width: 98rpx;
				height: 98rpx;
				border-radius: 50%;
				background: #354e44;
	
				image {
					margin-top: 20rpx;
					margin-left: 20rpx;
					width: 60rpx;
					height: 60rpx;
				}
			}
		}
	}
	
	.find-center {
		border-radius: 50rpx;
		width: 674rpx;
		height: 482rpx;
		margin: 0 auto;
		margin-bottom: 40rpx;
	
	
		.top {
			width: 100%;
			height: 382rpx;
			background: red;
			position: relative;
	
			image {
				width: 100%;
				height: 100%;
			}
	
			.text {
				margin-left: 20rpx;
				position: absolute;
				top: 260rpx;
				color: #fff;
	
			}
		}
	
		.under {
			width: 100%;
			height: 100rpx;
			background: #fff;
			display: flex;
			justify-content: space-between;
	
			image {
				margin: 30rpx 40rpx;
				width: 60rpx;
				height: 43rpx;
			}
		}
	}
</style>
